﻿
var allTaskCodes = "";
var currentTask = "";
var hdnSessionValue = "";
$(function () {
    try
    {
        hdnSessionValue=$("#hdnSessionValue").val();
    }
    catch(ex)
    {
    }
});
$("#extras, #mobextras").live("click", function (e) {
  
    $("#divTaskDetail, #divTaskCustomize, #divTaskCreate , .detail-page-tipsdetail, .detail-page-ideasdetail, .helpScreenByScreen, .faqPage ").hide();
   
    window.scrollTo(0, 0);
    if (hdnSessionValue == "iphoneApp" || hdnSessionValue == "ipadApp") {
        $(".mobileMenu").show();
    }
 });
$("#admin ,#mobadmin").live("click", function (e) {
   
    $("#divTaskDetail, #divTaskCustomize, #divTaskCreate , .detail-page-tipsdetail, .detail-page-ideasdetail, .helpScreenByScreen, .faqPage").hide();
    window.scrollTo(0, 0);
    if (hdnSessionValue == "iphoneApp" || hdnSessionValue == "ipadApp") {
        $(".mobileMenu").show();
    }
 });
$("#tasks ,#mobtasks").live("click", function (e) {

    $("#divTaskDetail, #divTaskCustomize, #divTaskCreate, .detail-page-tipsdetail, .detail-page-ideasdetail, .helpScreenByScreen, .faqPage").hide();
    $("#divTasks").show();
    window.scrollTo(0, 0);
    //if ($("#divTasks").html().trim() == '') {
        //for iphoneApp, androidApp, ipadApp we donn't need to show the loader.
       
        if (hdnSessionValue == "iphoneApp" || hdnSessionValue == "androidApp" || hdnSessionValue == "ipadApp") {
            $("#wait_tasktipsideas").css("display", "none");
           }
        else {
            $("#wait_tasktipsideas").css("display", "block");
        }

       $("#divTasks").load("/Mtt/tasks", function () {
        
            $("#wait_tasktipsideas").css("display", "none");
            if ($(this).html() == '') {
                window.location.href = "/home/login"
            }
        });

   // }
    if (hdnSessionValue == "iphoneApp" || hdnSessionValue == "ipadApp") {
        $(".mobileMenu").show();
    }
    $(".task-tab").show();
    $(".tips-tab, .ideas-tab, .extras-tab, .admin-tab").hide();

});

$("#tips, #mobtips").live("click", function (e) {
    window.scrollTo(0, 0);
    $("#divTaskDetail, #divTaskCustomize, #divTaskCreate, .detail-page-tipsdetail, .detail-page-ideasdetail, .helpScreenByScreen, .faqPage").hide();
    //if ($("#divTips").html().trim() == '') {
        $("#wait_tasktipsideas").css("display", "block");
        $("#divTips").load("/Mtt/tips", function () {
            $("#wait_tasktipsideas").css("display", "none");
            if ($(this).html() == '') {
                window.location.href = "/home/login"
            }
        });
    //}
    if (hdnSessionValue == "iphoneApp" || hdnSessionValue == "ipadApp") {
        $(".mobileMenu").show();
    }
 
    $(".task-tab, .ideas-tab, .extras-tab, .admin-tab").hide();
    $(".tips-tab").show();
});


$("#ideas, #mobideas").live("click", function (e) {
    $("#divTaskDetail, #divTaskCustomize, #divTaskCreate, .detail-page-tipsdetail, .detail-page-ideasdetail, .helpScreenByScreen, .faqPage").hide();
    window.scrollTo(0, 0);
    //if ($("#divIdeas").html().trim() == '') {
        $("#wait_tasktipsideas").css("display", "block");
        $("#divIdeas").load("/Mtt/ideas", function () {
            $("#wait_tasktipsideas").css("display", "none");
            if ($(this).html() == '') {
                window.location.href = "/home/login"
            }
        });
   // }
    if (hdnSessionValue == "iphoneApp" || hdnSessionValue == "ipadApp") {
        $(".mobileMenu").show();
    }
    $(".task-tab, .tips-tab, .extras-tab, .admin-tab").hide();
    $(".ideas-tab").show();
});



//Tasks/ Tips / ideas
$(".clsimgDone").live("click", function () {

    //Used for Image Toggle
    var original_data_alt = $(this).attr('data-alt');
    var original_src = $(this).attr('src');

    $(this).attr('src', original_data_alt);
    $(this).attr('data-alt', original_src);

    //Used for Update in Database
    var taskCode = $(this).attr("data-taskcode");
    var month = $("#hdnselectedmonth").val();
    var year = $("#hdnselectedyear").val();
    var updateDone = $("#hdnUpdateDone").val();
    var status = "Y";
   
    if ($(this).attr('data-status') == "Y")
    {
        status = "N";
    }
   
    $(this).attr('data-status', status);
   
    //Send Ajax Request to Server.
    $.ajax({
        type: "POST",
        //async: false,
        url: updateDone,
        data: { "taskCode": taskCode, "month": month, "year": year, "status": status },
        success: function (data) {
            var returnData = data;
           
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert('Failed to retrieve states.');

        }

    });

 });


$("#btnMYDone").live("click", function () {
    
    if (oldHomeNumberTask != $("#getMonths").val() || oldYear != $("#getYear").val()) {
        var hdnupdateothermonths = $("#hdnupdateothermonths").val();
        btnMYDone(hdnupdateothermonths);
    }
    
});
$("#btnMYDoneList").live("click", function () {
  
    
    var homeNumber = "";
        if ($("#getSingleHomeName").val() != "") {
            homeNumber = $("#getSingleHomeName").val();
    }
    else {
            homeNumber = $("#getHomeName").val();
        }
        var display = $("#getDisplay").val();
        var sortBy = $("#getSortBy").val();
        if (oldHomeNumberTask != homeNumber || oldTaskDisplay != display || oldTaskSortBy != sortBy) {
            $("#wait_tasktipsideas").css("display", "block");
            $.ajax({
                type: "POST",
                url: "/mtt/TaskDisplay",
                data: { "homeNumber": homeNumber, "display": display, "sortBy": sortBy },
                success: function (data) {
                    if (data != "") {
                        $("#divTasks").html('');
                        $("#divTasks").html(data);

                    }
                    else {
                        window.location.href = "/home/login"
                        return false;
                    }
                    $("#wait_tasktipsideas").css("display", "none");
                    $("#spnAllTasks").text($("#getDisplay option:selected").text());
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert('Failed to retrieve states.');
                    $("#wait_tasktipsideas").css("display", "none");
                }

            });
        }
   
});
$("#btnMYDoneTipDone").live("click", function () {
    
    if (oldHomeNumberTip != $("#getHomeNameTip").val()) {
        var homeNumber = $("#getHomeNameTip").val();
        $("#wait_tasktipsideas").css("display", "block");
        $.ajax({
            type: "POST",
            url: "/mtt/TipsByHome",
            data: { "homeNumber": homeNumber },
            success: function (data) {
                if (data != "") {
                    $("#divTips").html('');
                    $("#divTips").html(data);
                } else {
                    window.location.href = "/home/login"
                    return false;
                }
                $("#wait_tasktipsideas").css("display", "none");
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert('Failed to retrieve states.');
                $("#wait_tasktipsideas").css("display", "none");
            }


        });
    }
    
});
$("#btnMYDoneIdeaDone").live("click", function () {
    if (oldHomeNumberIdea != $("#getHomeNameIdea").val())
    {
        var homeNumber = $("#getHomeNameIdea").val();
        $("#wait_tasktipsideas").css("display", "block");
        $.ajax({
            type: "POST",
            url: "/mtt/IdeasByHome",
            data: { "homeNumber": homeNumber },
            success: function (data) {
                if (data != "") {
                    $("#divIdeas").html('');
                    $("#divIdeas").html(data);
                }
                else {
                    window.location.href = "/home/login"
                    return false;
                }
                $("#wait_tasktipsideas").css("display", "none");
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert('Failed to retrieve states.');
                $("#wait_tasktipsideas").css("display", "none");
            }


        });
    }

});

function btnMYDone(hdnupdateothermonths) {
    var selectedyear = $("#getYear").val();
    var selectedmonth = $("#getMonths").val();
    $("#wait_tasktipsideas").css("display", "block");
    if (selectedyear != '' && selectedmonth != '') {
        $.ajax({
            type: "POST",
            url: hdnupdateothermonths,
            data: { "year": selectedyear, "month": selectedmonth },
            success: function (data) {
               
                $("#divTasks").html('');
                $("#divTasks").html(data);
               
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert('Failed to retrieve states.');

            }

        });
    }
    $("#wait_tasktipsideas").css("display", "none");
}



$(".taskDetailClick").live("click", function () {
    $("#wait_tasktipsideas").css("display", "block");
    $("#divTasks, .detail-page-tipsdetail").hide()
    allTaskCodes = "";
    var taskCode = $(this).attr("data-taskcode").trim();
    var allTaskCodesArray = null;
    $(".taskDetailClick").each(function () {
        allTaskCodes += $(this).attr("data-taskcode").trim() + ",";
    });
    var i;
    allTaskCodesArray = allTaskCodes.split(',');
    for (i = 0 ; i < allTaskCodesArray.length - 1; i++) {
        if (taskCode == allTaskCodesArray[i] && i < allTaskCodesArray.length) {
            break;
        }
    }
    GetTaskDetail(taskCode, i, allTaskCodesArray.length,"simpleClick");
    window.scrollTo(0, 0);
   
});





function GetTaskDetail(taskCode, i, totalTaskLength, condition) {
    $.ajax({
        type: "POST",
        url: "/Mtt/TaskDetail",
        data: { "taskCode": taskCode },
        success: function (data) {
            
            if (data == "") {
                window.location.href = "/home/login"
                return false;
            }
            if (condition == "simpleClick") {
               
                $("#divTaskDetail").html(data);
                if (i == totalTaskLength - 2) {
                    $(".btnNextTask").css('font-weight', 'normal');
                    $("#btnNextTask").css('color', '#565656');
                }
                else {
                    $(".btnNextTask").css('font-weight', 'bold');
                    $("#btnNextTask").css('color', '#FFFFFF');
                }
                if (i == 0) {
                    $(".btnPreviousTask").css('font-weight', 'normal');
                    $("#btnPreviousTask").css('color', '#565656');
                }
                else {
                    $(".btnPreviousTask").css('font-weight', 'bold');
                    $("#btnPreviousTask").css('color', '#FFFFFF');
                }
               
            }
            else if (condition == "previousClick") {
                $("#divTaskDetail").html();
                $("#divTaskDetail").html(data);

                $(".btnNextTask").css('font-weight', 'bold');
                $("#btnNextTask").css('color', '#FFFFFF');

                if (i == 1) {
                    $(".btnPreviousTask").css('font-weight', 'normal');
                    $("#btnPreviousTask").css('color', '#565656');
                }
                else {
                    $(".btnPreviousTask").css('font-weight', 'bold');
                    $("#btnPreviousTask").css('color', '#FFFFFF');
                }
            }
            else if (condition == "nextClick") {
                $("#divTaskDetail").html();
                $("#divTaskDetail").html(data);

                if (i == totalTaskLength - 3) {
                    $(".btnNextTask").css('font-weight', 'normal');
                    $("#btnNextTask").css('color', '#565656');
                }
                else {
                    $(".btnNextTask").css('font-weight', 'bold');
                    $("#btnNextTask").css('color', '#FFFFFF');
                }
                $("#btnPreviousTask").css('color', '#FFFFFF');
                $(".btnPreviousTask").css('font-weight', 'bold');
            }
            $("#divTaskDetail").show();
            $("#wait_tasktipsideas").css("display", "none");
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $("#wait_tasktipsideas").css("display", "none");
            alert('Failed to retrieve states.');
        }


    });
}

$(".btnPreviousTask").live("click", function () {
    $("#divTasks,.detail-page-tipsdetail").hide()
    currentTask = "";
    currentTask = $(this).attr("data-taskcode").trim();
    var allTaskCodesArray = null;
    var previousTask = "";
    allTaskCodesArray = allTaskCodes.split(',');
    var i;
    for (i = 0 ; i < allTaskCodesArray.length-1; i++)
    {
        if (currentTask == allTaskCodesArray[i] && i > 0) {
            previousTask = allTaskCodesArray[i - 1]
            
            break;

        }
        else {
            false;
        }
    }
    
    if (previousTask != "")
    {
        $("#wait_tasktipsideas").css("display", "block");
        GetTaskDetail(previousTask, i, allTaskCodesArray.length, "previousClick");
       
    }
    
    
});
$(".btnNextTask").live("click", function () {
    $("#divTasks, .detail-page-tipsdetail").hide()
    currentTask = "";
    currentTask = $(this).attr("data-taskcode").trim();
    var allTaskCodesArray = [];
    var nextTask = "";
    allTaskCodesArray = allTaskCodes.split(',');
    var i;
    for (i = 0 ; i < allTaskCodesArray.length-1; i++) {
        if (currentTask == allTaskCodesArray[i] && i < allTaskCodesArray.length) {
            nextTask = allTaskCodesArray[i + 1]
            break;

        }
        else {
            false;
        }
    }
    if (nextTask != "") {
        $("#wait_tasktipsideas").css("display", "block");
        GetTaskDetail(nextTask, i, allTaskCodesArray.length, "nextClick");
       
    }

});

$("#btnBackTasksList").live("click", function () {
    $("#divTaskDetail").hide();
    $("#divTasks").show();

    checkscreenWidthTasks();
});



$("#btnBackTaskCustomize").live("click", function () {
    $("#divTaskCustomize").hide();
    $("#divTaskDetail").show();
    checkscreenWidthTaskHide();
    
});


function checkscreenWidthTaskHide() {

    var $window = $(window);
    var windowsize = $window.width();

    if (windowsize < 767) {
        $(".mobileMenu").hide();
    }
}



function checkscreenWidthTasks() {

    var $window = $(window);
    var windowsize = $window.width();

    if (windowsize < 767) {
        $(".mobileMenu").show();
    }
    else {
        $(".mobileMenu").hide();
    }

}



$("#taskCustomizeClick").live("click", function () {

   
    checkscreenWidthTasks();
    $("#wait_tasktipsideas").css("display", "block");
    var taskCode = $('#hdnTaskCode').val();

    $("#divTaskCustomize").show();

    $.ajax({
        type: "POST",
        url: "/Mtt/TaskCustomize",
        data: {"taskCode": taskCode },
        success: function (data) {
            if (data == "") {
                window.location.href = "/home/login"
                return false;
            }
            $("#divTaskDetail").hide()
            $("#divTaskCustomize").html(data);
            $("#wait_tasktipsideas").css("display", "none");
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $("#wait_tasktipsideas").css("display", "none");
            alert('Failed to retrieve states.');
        }

    });
    window.scrollTo(0, 0);
});


$("#taskChangeClick").live("click", function () {
    $("#wait_tasktipsideas").css("display", "block");
    var taskCode = $('#hdnTaskCode').val();

    $("#divTaskCreate").show();

    $.ajax({
        type: "POST",
        url: "/Mtt/TaskChange",
        data: { "taskCode": taskCode },
        success: function (data) {
            if (data == "") {
                window.location.href = "/home/login"
                return false;
            }
            $("#divTaskCustomize").hide()
            $("#divTaskCreate").html(data);
            $("#wait_tasktipsideas").css("display", "none");
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $("#wait_tasktipsideas").css("display", "none");
            alert('Failed to retrieve states.');
        }

    });
    window.scrollTo(0, 0);
});


$("#btnBackCreateCustom").live("click", function () {
    $("#divTaskCreate").hide();
    $("#divTaskCustomize").show();
});

// Task Change Page

$("#getHomeName").live("change", function () {
    $("#home_number").val($(this).val());
});
$("#getCycle").live("change", function () {
    $("#cycle_timing").val($(this).val());
});
$("#getPriority").live("change", function () {
    $("#priority").val($(this).val());
});
$("#getEnergySavings").live("change", function () {
    $("#energy_savings_score").val($(this).val());
});
$("#getCostScore").live("change", function () {
    $("#cost_score").val($(this).val());
});
$("#getType").live("change", function () {
    $("#type").val($(this).val());
});

function benifitIconTexts(index) {
    var benifitIconText = new Array(12);
    benifitIconText[0] = "Energy Savings";
    benifitIconText[1] = "Health & Safety";
    benifitIconText[2] = "Avoiding Unscheduled Repairs";
    benifitIconText[3] = "Comfort & Convenience";
    benifitIconText[4] = "Maintaining Value";
    benifitIconText[5] = "Appearance";
    benifitIconText[6] = "Green (saving water & recycling)";
    benifitIconText[7] = "Saving Money (beyond energy)";
    benifitIconText[8] = "Space Management (including decluttering)";
    benifitIconText[9] = "Allergy Control";
    benifitIconText[10] = "Child Safety";
    benifitIconText[11] = "Senior Safety";
    return benifitIconText[index];
}
function benifitIcons(index) {
    var benifitIcon = new Array(12);
    benifitIcon[0] = "Energy Savings";
    benifitIcon[1] = "Safety & Health";
    benifitIcon[2] = "Avoiding Unscheduled Repairs";
    benifitIcon[3] = "Comfort & Convenience";
    benifitIcon[4] = "Maintaining Value";
    benifitIcon[5] = "Appearance";
    benifitIcon[6] = "Green";
    benifitIcon[7] = "Saving Money";
    benifitIcon[8] = "Space Management";
    benifitIcon[9] = "Allergy Control";
    benifitIcon[10] = "Especially for Children";
    benifitIcon[11] = "Especially for Elderly";
    return benifitIcon[index];
}

$(".tips-Detail-Page").live("click", function () {

    $(".tips-tab").hide();
    $(".mobileMenu").hide();
    tipDetail($(this));
    var allTipsCodes = "";
    var allTipCodesArray = null;
    $(".tips-Detail-Page").each(function () {
        allTipsCodes += $(this).attr("data-code").trim() + ",";
    });
    var i;
    allTipCodesArray = allTipsCodes.split(',');
    for (i = 0 ; i < allTipCodesArray.length - 1; i++) {
        if ($(this).attr("data-code").trim() == allTipCodesArray[i] && i < allTipCodesArray.length) {
            break;

        }
        else {
            false;
        }
    }
    if (i == allTipCodesArray.length - 2) {
        $(".btnNextTip").css('font-weight', 'normal');
        $("#btnNextTip").css('color', '#565656');
    }
    else {
        $(".btnNextTip").css('font-weight', 'bold');
        $("#btnNextTip").css('color', '#FFFFFF');
    }
    if (i == 0) {
        $(".btnPreviousTip").css('font-weight', 'normal');
        $("#btnPreviousTip").css('color', '#565656');
    }
    else {
        $(".btnPreviousTip").css('font-weight', 'bold');
        $("#btnPreviousTip").css('color', '#FFFFFF');
    }
    $(".detail-page-tipsdetail").show();

    $("#tipsDetailMonthYear").html($(this).attr("data-monthyear"));


});//data-tip_priority
$("#back-buttonTipsDetail").live("click", function () {
    $(".tips-tab").show();
    $(".detail-page-tipsdetail").hide();
  
});

$(".btnPreviousTip").live("click", function () {
    var allTipsCodes = "";
    var allTipCodesArray = null;
    var previousTip = "";
    var tipCode = $(this).attr("data-taskcode").trim();
    $(".tips-Detail-Page").each(function () {
        allTipsCodes += $(this).attr("data-code").trim() + ",";
    });
    var i;
    allTipCodesArray = allTipsCodes.split(',');
    for (i = 0 ; i < allTipCodesArray.length - 1; i++) {
        if (tipCode == allTipCodesArray[i] && i > 0) {
            previousTip = allTipCodesArray[i - 1]
            break;

        }
        else {
            false;
        }
    }
    if (previousTip != "") {
        $(".tips-Detail-Page").each(function () {

            if (previousTip == $(this).attr("data-code").trim()) {
                tipDetail($(this));
                $(".btnPreviousTip").attr("data-taskCode", $(this).attr("data-code").trim());
                $(".btnNextTip").attr("data-taskCode", $(this).attr("data-code").trim())
                $(".btnNextTip").css('font-weight', 'bold');
                $("#btnNextTip").css('color', '#FFFFFF');
                if (i == 1) {
                    $(".btnPreviousTip").css('font-weight', 'normal');
                    $("#btnPreviousTip").css('color', '#565656');
                }
                else {
                    $(".btnPreviousTip").css('font-weight', 'bold');
                    $("#btnPreviousTip").css('color', '#FFFFFF');
                }
                false;
            }
        });
    } else {
        false;
    }

});
$(".btnNextTip").live("click", function () {

    var allTipsCodes = "";
    var allTipCodesArray = null;
    var nexTip = "";
    var tipCode = $(this).attr("data-taskcode").trim();

    $(".tips-Detail-Page").each(function () {
        allTipsCodes += $(this).attr("data-code").trim() + ",";
    });
    var i;
    allTipCodesArray = allTipsCodes.split(',');
    for (i = 0 ; i < allTipCodesArray.length - 1; i++) {
        if (tipCode == allTipCodesArray[i] && i < allTipCodesArray.length) {
            nexTip = allTipCodesArray[i + 1]
            break;

        }
        else {
            false;
        }
    }
    if (nexTip != "") {
        $(".tips-Detail-Page").each(function () {

            if (nexTip == $(this).attr("data-code").trim()) {
                tipDetail($(this));
                if (i == allTipCodesArray.length - 3) {
                    $(".btnNextTip").css('font-weight', 'normal');
                    $("#btnNextTip").css('color', '#565656');
                }
                else {
                    $(".btnNextTip").css('font-weight', 'bold');
                    $("#btnNextTip").css('color', '#FFFFFF');
                }
                $("#btnPreviousTip").css('color', '#FFFFFF');
                $(".btnPreviousTip").css('font-weight', 'bold');
            }
        });
    } else {
        false;
    }

});
$("#back-buttonIdeasDetail").live("click", function () {
    $(".ideas-tab").show();
    $(".detail-page-ideasdetail").hide();
});

$(".backToIdea").live("click", function () {
    $(".mobileMenu").show();
});
$(".backToTips").live("click", function () {
    $(".mobileMenu").show();
});
$(".ideas-Detail-Page").live("click", function () {
    ideaDetail($(this));
    var allideasCodes = "";
    var allideaCodesArray = null;
    $(".ideas-Detail-Page").each(function () {
        allideasCodes += $(this).attr("data-idea_code").trim() + ",";
    });
    var i;
    allideaCodesArray = allideasCodes.split(',');
    for (i = 0 ; i < allideaCodesArray.length - 1; i++) {
        if ($(this).attr("data-idea_code").trim() == allideaCodesArray[i] && i < allideaCodesArray.length) {
            break;

        }
        else {
            false;
        }
    }
    if (i == allideaCodesArray.length - 2) {
        $(".btnNextidea").css('font-weight', 'normal');
        $("#btnNextidea").css('color', '#565656');
    }
    else {
        $(".btnNextidea").css('font-weight', 'bold');
        $("#btnNextidea").css('color', '#FFFFFF');
    }
    if (i == 0) {
        $(".btnPreviousidea").css('font-weight', 'normal');
        $("#btnPreviousidea").css('color', '#565656');
    }
    else {
        $(".btnPreviousidea").css('font-weight', 'bold');
        $("#btnPreviousidea").css('color', '#FFFFFF');
    }
    $(".detail-page-ideasdetail").show();
});
$(".btnNextidea").live("click", function () {
   
    var allIdeasCodes = "";
    var allIdeaCodesArray = null;
    var nexIdea = "";
    var ideaCode = $(this).attr("data-taskcode").trim();

    $(".ideas-Detail-Page").each(function () {
        allIdeasCodes += $(this).attr("data-idea_code").trim() + ",";
    });
    
    var i;
    allIdeaCodesArray = allIdeasCodes.split(',');
    for (i = 0 ; i < allIdeaCodesArray.length - 1; i++) {
        if (ideaCode == allIdeaCodesArray[i] && i < allIdeaCodesArray.length) {
            nexIdea = allIdeaCodesArray[i + 1]
            break;

        }
        else {
            false;
        }
    }
   
    if (nexIdea != "") {
        $(".ideas-Detail-Page").each(function () {

            if (nexIdea == $(this).attr("data-idea_code").trim()) {
                ideaDetail($(this));
                if (i == allIdeaCodesArray.length - 3) {
                  
                    $(".btnNextidea").css('font-weight', 'normal');
                    $("#btnNextidea").css('color', '#565656');
                }
                else {
                    $(".btnNextidea").css('font-weight', 'bold');
                    $("#btnNextidea").css('color', '#FFFFFF');
                }
                $("#btnPreviousidea").css('color', '#FFFFFF');
                $(".btnPreviousidea").css('font-weight', 'bold');
            }
            false;
        });
    } else {
        false;
    }

});
$(".btnPreviousidea").live("click", function () {
    var allideasCodes = "";
    var allideaCodesArray = null;
    var previousIdea = "";
    var ideaCode = $(this).attr("data-taskcode").trim();
    $(".ideas-Detail-Page").each(function () {
        allideasCodes += $(this).attr("data-idea_code").trim() + ",";
    });
    var i;
    allideaCodesArray = allideasCodes.split(',');
    for (i = 0 ; i < allideaCodesArray.length - 1; i++) {
        if (ideaCode == allideaCodesArray[i] && i > 0) {
            previousIdea = allideaCodesArray[i - 1]
            break;

        }
        else {
            false;
        }
    }
    if (previousIdea != "") {
        $(".ideas-Detail-Page").each(function () {

            if (previousIdea == $(this).attr("data-idea_code").trim()) {
               
                ideaDetail($(this));
                $(".btnNextidea").css('font-weight', 'bold');
                $("#btnNextidea").css('color', '#FFFFFF');
                if (i == 1) {
                    $(".btnPreviousidea").css('font-weight', 'normal');
                    $("#btnPreviousidea").css('color', '#565656');
                }
                else {
                    $(".btnPreviousidea").css('font-weight', 'bold');
                    $("#btnPreviousidea").css('color', '#FFFFFF');
                }
                false;
            }
        });
    }
});

function ideaDetail(currentObject) {
    $(".ideas-tab").hide();
    $(".mobileMenu").hide();
    $("#ideaImage").attr("src", "../" + currentObject.attr("data-display_icon_code"));
    $("#ideaTitle").html(currentObject.attr("data-idea_title"));
    $("#ideaContent").html(currentObject.attr("data-idea_content"));
    $("#ideaPriority").attr("src", "../images/detail-page-img/star" + currentObject.attr("data-idea_priority") + "-d.png");
    $("#ideaBenifitContent").html(currentObject.attr("data-idea_benefit_content"));
    $("#idea_cost_content").html(currentObject.attr("data-idea_cost_content"));
    if (currentObject.attr("data-idea_energy_savings_content").trim() == "") {
        $("#lblidea_energy_savings_content").hide();
        $("#idea_energy_savings_content").html("");
    } else {
        $("#lblidea_energy_savings_content").show();
        $("#idea_energy_savings_content").html(currentObject.attr("data-idea_energy_savings_content"));
    }
    $("#idea_cost_score").attr("src", "../images/task/costs icons" + currentObject.attr("data-idea_cost_score") + ".png")
    $("#idea_energy_savings_score").attr("src", "/images/task/energysavings" + currentObject.attr("data-idea_energy_savings_score") + ".png");
    $("#idea_cost_score").attr("src", "/images/task/costs icons" + currentObject.attr("data-idea_cost_score") + ".png");
    $("#ideaBenifitIcon").html('');
    var benefitString = currentObject.attr("data-benefits_str").trim();
    var benefits_str = [];
    benefits_str = benefitString.split(',');
    for (var j = 0 ; j < benefits_str.length - 1; j++) {
        $("#ideaBenifitIcon").append("<li> <img style='width:14px;height:15px;' src='../images/benefits icons/" + benifitIcons(benefits_str[j]) + ".png' alt=''><span>" + benifitIconTexts(benefits_str[j]) + "</span></li>");
    }
    switch (currentObject.attr("data-idea_type")) {
        case "1":
            $("#ideaType").html("inside");
            break;
        case "2":
            $("#ideaType").html("outside");
            break;
        case "3":
            $("#ideaType").html("other");
            break;
        default:
            $("#ideaType").html("");
            break;
    }
    $(".btnPreviousidea").attr("data-taskCode", currentObject.attr("data-idea_code").trim());
    $(".btnNextidea").attr("data-taskCode", currentObject.attr("data-idea_code").trim());
}
function tipDetail(currentObject) {
    $("#tipImage").attr("src", "../" + currentObject.attr("data-display_icon_code"));
    $("#tipTitle").html(currentObject.attr("data-tip_title"));
    $("#tipContent").html(currentObject.attr("data-tip_content"));
    $("#tipPriority").attr("src", "../images/detail-page-img/star" + currentObject.attr("data-tip_priority") + "-d.png");
    $("#tipBenifitContent").html(currentObject.attr("data-tip_benefit_content"));
    $("#tip_cost_content").html(currentObject.attr("data-tip_cost_content"));
    if (currentObject.attr("data-tip_energy_savings_content").trim() == "") {
        $("#lbltip_energy_savings_content").hide();
        $("#tip_energy_savings_content").html("");
    } else {
        $("#lbltip_energy_savings_content").show();
        $("#tip_energy_savings_content").html(currentObject.attr("data-tip_energy_savings_content"));
    }
    $("#tip_cost_score").attr("src", "../images/task/costs icons" + currentObject.attr("data-tip_cost_score") + ".png")
    $("#tip_energy_savings_score").attr("src", "/images/task/energysavings" + currentObject.attr("data-tip_energy_savings_score") + ".png");
    $("tip_cost_score").attr("src", "/images/task/costs icons" + currentObject.attr("data-tip_cost_score") + ".png");
    $("#tipBenifitIcon").html('');
    var benefitString = currentObject.attr("data-benefits_str").trim();
    var benefits_str = [];
    benefits_str = benefitString.split(',');
    for (var j = 0 ; j < benefits_str.length - 1; j++) {
        $("#tipBenifitIcon").append("<li> <img style='width:14px;height:15px;' src='../images/benefits icons/" + benifitIcons(benefits_str[j]) + ".png' alt=''><span>" + benifitIconTexts(benefits_str[j]) + "</span></li>");
    }
    switch (currentObject.attr("data-tip_type")) {
        case "1":
            $("#tipType").html("inside");
            break;
        case "2":
            $("#tipType").html("outside");
            break;
        case "3":
            $("#tipType").html("other");
            break;
        default:
            $("#tipType").html("");
            break;
    }
    $(".btnPreviousTip").attr("data-taskCode", currentObject.attr("data-code").trim());
    $(".btnNextTip").attr("data-taskCode", currentObject.attr("data-code").trim());

}